package cn.itcast.flink.source;

import org.apache.flink.streaming.api.datastream.DataStreamSource;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;

/**
 * @author lilulu
 */
public class StreamSourceFileDemo {
    public static void main(String[] args) throws Exception {
        // 1. 执行环境-env
        StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
        env.setParallelism(1);
        // 2. 数据源-source
        //读取文本文件
        DataStreamSource<String> source = env.readTextFile("datas/words.txt");
        source.print();
        System.out.println("===================");
//        读取压缩文件
        DataStreamSource<String> source1 = env.readTextFile("datas/words.txt.gz");
//        source1.print();
        // 3. 数据转换-transformation
        // 4. 数据终端-sink
        // 5. 触发执行-execute
        env.execute("StreamSourceFileDemo");
    }
}